import React from 'react'
// ===================================================================== Temp
import Table from '#cpt/temp/Table'
import TableControls from '#cpt/temp/TableControls'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const ControlModal 		= $Lazy.state(()=>import('./control-modal'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
	}
	
	model = {}
	
	load = ({ region_id, hosp_id, salesman_id, parent_kind_id, item_id, start_at, end_at  }) => {
		this.query = { region_id, hosp_id, salesman_id, parent_kind_id, item_id, start_at, end_at }
		this.model = { current:1 }
		this.fetch()
	}
	
	// 查询项目paging
	fetch = () => $fn.fetch.call(this,'bill-st/detailindex',{isIndex:true })
	
	// 关联表单
	cols = [
		{ title: '岗位',					dataIndex: 'project_name', 				width:150 },
		{ title: '接收时间',				dataIndex: 'check_time', 				...$fn.table.time },
		{ title: '客户名称',				dataIndex: 'hosp_name', 				width:250 },
		{ title: '条码号',				dataIndex: 'old_spec_code', 			...$fn.table.spec_code },
		{ title: '自然项目',				dataIndex: 'parent_kind_name', 			width:250 },
		{ title: '项目名称',				dataIndex: 'kind_name', 				width:250 },
		{ title: '标准价格',				dataIndex: 'sprice', 					...$fn.table.num },
		{ title: '实际价格',				dataIndex: 'price', 					width:100 },
		{ title: '姓名',					dataIndex: 'patient_name', 				...$fn.table.name },
		{ title: '性别',					dataIndex: 'sex_name', 					width:100 },
		{ title: '年龄',					dataIndex: 'age', 						...$fn.table.age },
		{ title: '送检科室',				dataIndex: 'department_name', 			width:150 },
		{ title: '医生',					dataIndex: 'doctor', 					...$fn.table.name },
		{ title: '备注',					dataIndex: 'remark', 					width:150 },
		{ title: '账单属性',				dataIndex: 'attribute_name', 			width:100 },
		{ title: '实验科室',				dataIndex: 'project_parent_name', 		width:150 },
		{ title: '开票单位（NC）',		dataIndex: 'organization_name', 		width:150 },
		{ title: '开票单位编码（NC）',	dataIndex: 'organization_code', 		width:150 },
		{ title: '业务员',				dataIndex: 'salesman_user', 			width:150 },
		{ title: '业务员编码',			dataIndex: 'salesman_code', 			width:150 },
		{ title: '区域',					dataIndex: 'region_name', 				width:150 },
		{ title: '区域编码',				dataIndex: 'region_num', 				width:150 },
		TableControls.controls.call(this)
		
	]

	// 表格操作按钮
	table_controls = (text, rows) => {
		return [
			TableControls.click.call(this, '账单信息', ()=> this.modal.open(rows) )
		]
	}
	
	render(){
		return (
			<>
				{/* 表格 */}
				{ Table.call(this,{type:1,onSelectOk:( key , rows ) => this.tableRef.fetch(rows), isIndex:true }) }
				{/* 账单信息 */}
				<ControlModal onRef={ref=>this.modal=ref} />
			</>
		)
	}
}

export default Index